#ifndef UART_H_
#define UART_H_
#include "stdarg.h"
#include "stdio.h"
void uartPrintf(const char *format,...)
{
 	va_list ap;
	char *p,*sval;
	int ival;
	double dval;
	char *tempS;
	int tempSLength;
	

	FILE * fp;
	fp = fopen(UART_0_NAME,"w");

	va_start(ap,format);
	for(p = format;*p;p++){
		if(*p != '%'){
			fwrite(p,sizeof(char),1,fp);
			continue;
			}
		else{
			switch(*++p){
			case 'd' :
				ival = va_arg(ap,int);
				fprintf(fp,"%d",ival);
				break;
			case 'x' :
				ival = va_arg(ap,int);
				fprintf(fp,"%x",ival);
				break;
			case 'f' :
				dval = va_arg(ap,double);
				fprintf(fp,"%f",dval);
				break;
			case 's' :
				for(sval = va_arg(ap,char*);*sval;sval++)
					fwrite(sval,sizeof(char),1,fp);
				break;
			default:
				fwrite(p,sizeof(char),1,fp);
				break;
				}
			}
		}
		
	va_end(ap);
	fclose(fp);
}
void uartprintf(const char *format,...)
{
    va_list ap;
    char *p,*sval;
    int ival;
    double dval;
    char *tempS;
    int tempSLength;
    

    FILE * fp;
    fp = fopen(UART_0_NAME,"w");

    va_start(ap,format);
    for(p = format;*p;p++){
        if(*p != '%'){
            fwrite(p,sizeof(char),1,fp);
            continue;
            }
        else{
            switch(*++p){
            case 'd' :
                ival = va_arg(ap,int);
                fprintf(fp,"%d",ival);
                break;
            case 'x' :
                ival = va_arg(ap,int);
                fprintf(fp,"%x",ival);
                break;
            case 'f' :
                dval = va_arg(ap,double);
                fprintf(fp,"%f",dval);
                break;
            case 's' :
                for(sval = va_arg(ap,char*);*sval;sval++)
                    fwrite(sval,sizeof(char),1,fp);
                break;
            default:
                fwrite(p,sizeof(char),1,fp);
                break;
                }
            }
        }
        
    va_end(ap);
    fclose(fp);
}
#endif /*UART_H_*/
